删除表中多余的重复记录,重复记录是根据单个字段peopleName来判断,只留有peopleId最小的记录:
1 2 3
| delete from people where peopleName in (select peopleName from people group by peopleName having count(peopleName) > 1) and peopleId not in (select min(peopleId) from people group by peopleName having count(peopleName) > 1);
|